import {Injectable} from '@angular/core';
import {SERVERS_NAME} from '../../../config/config';
import {HttpService} from '../../../core/http.service';
import {Observable} from 'rxjs';
import {CommHttpService} from '../../../core/comm.http.service';

@Injectable()
export class NewsService extends CommHttpService {
    // base url
    protected preUrl = `${SERVERS_NAME.SECURITY_SERVER}sys/message/`;

    constructor(protected http: HttpService) {
        super(http);
    }

// interface module
    /**
     * 判断是否有发送消息权限
     */
    canSend(): Observable<any> {
        return this.http.get({}, `${this.preUrl}checkSendPerm`);
    }
    /**
     * 获取数量
     */
    getCount(): Observable<any> {
        return this.http.get({}, `${this.preUrl}count`);
    }

    /**
     * 发布消息
     * @param param:提交参数
     */
    sendInfoFn(param: any): Observable<any> {
        return this.http.post(param, `${this.preUrl}send`);
    }

    /**
     * 标记已读-未读
     * @param data：数据参数
     * @param urlStr:已读-未读字符标识
     */
    signReadList(data:Array<string>,urlStr:string): Observable<any> {
        return this.http.post(data, `${this.preUrl}${urlStr}`,false);
    }

    /**
     * 标记全部已读
     * @param data:提交参数
     */
    readAll(data: { [key: string]: number }): Observable<any> {
        return this.http.post(data, `${this.preUrl}signAllRead`,false);
    }

    /**
     * 查询教师
     */
    teacherPage(data): Observable<any> {
        return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/teacher/page`, false);
    }

    /**
     * 查询职务/职称/任职类型 --- 过滤时使用
     */
    threeList(param:string):Observable<any> {
        return this.http.post({}, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/dictionary/listFilter/' + param, false);
    }

    /**
     * 查询学生
     */
    studentPage(data): Observable<any> {
        return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/student/page`, false);
    }

    /**
     * 查询学院列表
     */
    getCollege() {
        return this.http.post({}, `${SERVERS_NAME.SECURITY_SERVER}sys/college/listCollege`, false);
    }

    /**
     * 查询学院树
     */
    getTree() {
        return this.http.get({}, `${SERVERS_NAME.SECURITY_SERVER}sys/college/tree`, false);
    }

    /**
     * 查询班级
     */
    classPage(data): Observable<any> {
        return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/classes/page`, false);
    }

    /**
     * 删除消息:删除消息
     * @param subArr:提交参数
     */
    sysDelete(subArr:Array<string>): Observable<any> {
        return this.http.post(subArr, `${this.preUrl}delete`);
    }
    /**
     * 查询选择的names
     */
    getNames(data:any): Observable<any> {
        return this.http.post(data, `${this.preUrl}findNames`);
    }


    /**
     * 删除消息
     */
    // sysDelete(data): Observable<any> {
    //     return this.http.post(data, `${this.preUrl}delete`);
    // }
}
